﻿<%@ page contentType="text/html;charset=utf-8"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="com.leruan.aasimp.entity.UserTypeEnumEntity" %>
<%@ page import="com.leruan.aasimp.util.StringUtils" %>
<%@page import="com.leruan.aasimp.entity.Forumuser"%>
<%@page import="java.util.List"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String username = request.getParameter("username");
String s = request.getParameter("state");
Long state =1l;
if(null!=s||"".equals(s)){
  state = Long.parseLong(request.getParameter("state"));
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gbk">
<LINK href="<%=path %>/mok/forum/admin/style/admin.css" type=text/css rel=stylesheet></LINK>
<SCRIPT src="../../forum/js/common.js" type=text/javascript></SCRIPT>
<SCRIPT src="../admin/js/admin.js" type=text/javascript></SCRIPT>
<script type="text/javascript">
function modifyUser(userId,username,nickname,state,grade,score,userType){
document.getElementById("m_userId").value=userId;
document.getElementById("m_username").value=username;
document.getElementById("m_nickname").value=nickname;
document.getElementById("m_state").value=state;
document.getElementById("m_grade").value=grade;
document.getElementById("m_score").value=score;
document.getElementById("modifyUser").style.display="block";
}
</script>
</HEAD>
<BODY topMargin=10 >
<TABLE cellSpacing=6 cellPadding=2 width="100%" border=0>
  <TBODY>
  <TR>
    <TD>
      <TABLE class=guide cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD>
		  <A onclick="parent.location='../index.htm'; return false;" href="#">后台管理首页</A>&nbsp;&raquo;&nbsp;编辑用户
			</TD></TR></TBODY></TABLE><BR>
      <FORM name="frmsearch"  action="serchUserForEdit" method=post>
      <TABLE class=info_tb cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR class=header>
          <TD colSpan=2>&nbsp;-&nbsp; 搜索用户</TD></TR>
        <TR>
          <TD class=altbg1 width="45%">用户名:</TD>
          <TD class=altbg2 align=right><INPUT size=40 name="username" value="<%=StringUtils.rtrim(null==username?"":username)%>"/>&nbsp;&nbsp;<input class="button" type="submit" value="搜索用户"/><span>*请注意检查用户名的空格</span> </TD></TR>
        <TR>
          <TD class=altbg1 width="45%">用户的访问状态:</TD>
          <TD class=altbg2>
		  	<INPUT class=radio type=radio value="1" name="state" <%=1==state ?"checked='checked'":""%>/> 正常状态 
			<INPUT class=radio type=radio value="2" name="state" <%=2==state ?"checked='checked'":""%>/> 禁止发言 
			<INPUT class=radio type=radio value="3" name="state" <%=3==state ?"checked='checked'":""%>/> 禁止访问</TD>
			</TR>
		</TBODY></TABLE>
      </FORM>
      <TABLE class="info_tb" cellSpacing=0 cellPadding=0 width="100%" border=0>
      <TBODY>
      <TR class=header>
        <TD>用户名</TD>
        <TD>昵称</TD>
        <TD>等级</TD>
        <TD>得分</TD>
        <TD>用户类型</TD>
        <TD>操作</TD>
        </TR>
        <c:forEach var="forumUser" items="${forumUser}">
            <TR align=middle>
              <TD class=altbg1 width="15%">${forumUser.username}</TD>
              <TD class=altbg2 width="15%">${forumUser.nickname}</TD>
              <TD class=altbg1 width="15%">${forumUser.state}</TD>
              <TD class=altbg2 width="15%">${forumUser.score}</TD>
              <TD class=altbg1 width="15%"><%=UserTypeEnumEntity.valueOf(1) %></TD>
              <TD width="20%">
              <a href="deleteUser?userId=${forumUser.userId}&username=<%=username %>&state=<%=state %>">删除</a>
              &nbsp;<a href="javascript:void(0);" onclick="modifyUser('${forumUser.userId}','${forumUser.username }','${forumUser.nickname }','${forumUser.state }','${forumUser.grade }','${forumUser.score }','${forumUser.userType }')">修改</a>
              <c:if test="${1==forumUser.state }">
              &nbsp;<a href="forbidSay?userId=${forumUser.userId}&username=${forumUser.username}&state=${forumUser.state}">禁止发言</a>
              &nbsp;<a href="forbidVisit?userId=${forumUser.userId}&username=${forumUser.username}&state=${forumUser.state}">禁止访问</a>
              </c:if>
              <c:if test="${2==forumUser.state }">
              &nbsp;<a href="normal?userId=${forumUser.userId}&username=${forumUser.username}&state=${forumUser.state}">正常状态</a>
              &nbsp;<a href="forbidVisit?userId=${forumUser.userId}&username=${forumUser.username}&state=${forumUser.state}">禁止访问</a>
              </c:if>
              <c:if test="${3==forumUser.state }">
              &nbsp;<a href="normal?userId=${forumUser.userId}&username=${forumUser.username}&state=${forumUser.state}">正常状态</a>
              &nbsp;<a href="forbidSay?userId=${forumUser.userId}&username=${forumUser.username}&state=${forumUser.state}">禁止发言</a>
              </c:if>
              </TD>
            </TR>
            </c:forEach>
        </TBODY>
        </TABLE>
         <div class="pageNo" id="pageNo">
                <a href="editUserQuery?no=1&username=<%=username %>&state=<%=state %>">首页</a>
                <c:if test="${sessionScope.pageNoSale != 1}">
                    <a href="editUserQuery?no=${sessionScope.pageNoSale-1}&username=<%=username %>&state=<%=state %>">上一页</a>
                </c:if>
                <c:forEach var="i" begin="${sessionScope.pageNoCenterSale -2 }"
                    end="${sessionScope.pageNoCenterSale + 2}">
                    <c:if test="${i <= sessionScope.totalNoSale }">
                        <c:choose>
                            <c:when test="${i == sessionScope.pageNoSale}">
                                <a href="javascript:void(0)">${i}</a>
                            </c:when>
                            <c:otherwise>
                                <a href="editUserQuery?no=${i}&username=<%=username %>&state=<%=state %>">${i}</a>
                            </c:otherwise>
                        </c:choose>
                    </c:if>
                </c:forEach>
                <c:if test="${sessionScope.pageNoSale +4 < sessionScope.totalNoSale}">
                    <a href="editUserQuery?no=${sessionScope.pageNoSale+1}&username=<%=username %>&state=<%=state %>">下一页</a>
                </c:if>
                <a href="editUserQuery?no=${sessionScope.totalNoSale}&username=<%=username %>&state=<%=state %>">末页</a>
                &nbsp;&nbsp;&nbsp;&nbsp;共有<label style="color: red;">${sessionScope.totalSale}</label>条信息
            </div>
      </TBODY></TABLE>
      <div id="modifyUser" style="display: none">
      <form action="modifyUser" method="post">
      <input type="hidden" name="h_username" value="<%=StringUtils.rtrim(null==username?"":username)%>" />
       <input type="hidden" name="h_state" value="<%=state%>"/>
      <TABLE class="info_tb" cellSpacing=0 cellPadding=0 width="98.5%" border=0 align="center">
      <TBODY>
      <TR class=header>
          <TD colSpan=2>&nbsp;-&nbsp; 修改用户</TD></TR>
        <TR>
      <TR>
         <TD class=altbg1 width="45%">用户名:</TD>
          <TD class=altbg2 align=right><input type="hidden" id="m_state" name="m_state"/><input type="hidden" id="m_userId" name="m_userId"/> <INPUT size=40 id="m_username" name="m_username" /></TD></TR>
        <TR>
         <TD class=altbg1 width="45%">昵称:</TD>
          <TD class=altbg2 align=right><INPUT size=40 readonly = "readonly"  id="m_nickname" name="m_nickname"/></TD></TR>
       <TR>
         <TD class=altbg1 width="45%">等级:</TD>
          <TD class=altbg2 align=right><INPUT size=40 id="m_grade" name="m_grade"/></TD></TR>
          <TR>
         <TD class=altbg1 width="45%">得分:</TD>
          <TD class=altbg2 align=right><INPUT type="number" size=40 id="m_score" name="m_score"/></TD></TR>
          <TR>
         <TD class=altbg1 width="45%">用户类型:</TD>
          <TD class=altbg2 align=right>
          <select id="userType" name="m_userType">
		    <%
		    for(UserTypeEnumEntity utee:UserTypeEnumEntity.values()){
		    %>
		        <option value="<%=utee.getValue() %>"><%=utee.getDescription() %></option>
		    <%
		    }
		    %>
		  </select>
		  <input class="button" type="submit" value="确定"/>
          </TD></TR>
        </TBODY>
        </TABLE>
      </form>
      </div>
</BODY></HTML>
